/*
 * @Description: 乘车消费退款账单界面
 * @Author: tao.xie
 * @Date: 2019-04-01 10:25:43
 * @Last Modified by: tao.xie
 * @Last Modified time: 2019-04-01 13:54:38
 */
<template>
  <route-bill-main
    :info-list="infoList"
    :detail-icon="detailIcon"
    :detail-msg="routeBill.title"
    :price="'+'+routeBill.payFee"
  />
</template>

<script>
import Vue from 'vue'
import RouteBillMain from '../components/RouteBillMain'
import { getRouteBill } from '../api/api.js'
import TradeBills from '../components/TradeBillsJS.js'
import { getUrlParamByKey } from 'vue-xiaobu-utils'
import { BUS_CONSUME_RETURN } from '../constants/TradeType.js'
export default {
  components: {
    'route-bill-main': RouteBillMain
  },
  data() {
    return {
      detailIcon: require('../assets/bus.png'),
      infoList: [],
      routeBill: {
        payFee: ''
      }
    }
  },
  mounted() {
    this._getRouteBill(getUrlParamByKey('tradeno'))
    Vue.$EventBus.$on('look', () => {
      this.look()
    })
  },
  methods: {
    _getRouteBill: async function (tradeno) {
      try {
        this.routeBill = await getRouteBill(tradeno)
        let copyinfolist = []
        copyinfolist.push({
          infoName: '支付状态',
          infoValue: '交易成功'
        })
        if (this.routeBill.payName) {
          copyinfolist.push({
            infoName: '退款方式',
            infoValue: this.routeBill.payName + (this.routeBill.bankCardNo ? ' (' + this.routeBill.bankCardNo + ')' : '')
          })
        }
        if (this.routeBill.refundReson) {
          copyinfolist.push({
            infoName: '退款原因',
            infoValue: this.routeBill.refundReson
          })
        }

        copyinfolist.push({
          infoName: '退款时间',
          infoValue: this.routeBill.payTime
        })
        copyinfolist.push({
          infoName: '账单编号',
          infoValue: this.routeBill.tradeNo
        })

        if (this.routeBill.tradeBills && this.routeBill.tradeBills.length > 0) {
          copyinfolist.push({
            infoName: '关联账单',
            infoValue: '查看',
            isButton: true,
            eventName: 'look'
          })
        }
        this.infoList = copyinfolist
      } catch (err) { }
    },
    look() {
      TradeBills.show(this.routeBill.tradeBills, BUS_CONSUME_RETURN)
    }
  }
}
</script>

<style>
</style>
